<?php 
class Pattern {
  var $_label;
	var $_pattern;
	var $_selected;
	
	function Pattern ($l = "unknown"){
		$this->_selected =  false;
		$this->_label = $l;
		$this->_pattern = array();
	}

	function euclidean_distance (array $__pattern){		
		$dist = 0.0;
		for($i = 0; $i < count($this->_pattern); $i++){
			$dist += ($this->_pattern[$i] - $__pattern[$i]) * ($this->_pattern[$i] - $__pattern[$i]);
		}
		return sqrt($dist);
	}
	
	function move_to(array $__pattern, $e){
		for($i = 0; $i < count($this->_pattern); $i++)
			$this->_pattern[$i] += ($__pattern[$i] - $this->_pattern[$i]) * $e;
	}	

	function half_to(array $__pattern){
		$middle = new Pattern();
		for($i = 0; $i < count($this->_pattern); $i++)
			$middle->_pattern[] = ($__pattern[$i] + $this->_pattern[$i]) / 2;
		return $middle;
	}		
}
?>